import request from "@/utils/request";



//添加或保存新闻
export function addOrUpdateNews(news) {
    return request({
        url: "/news",
        method: "post",
        data: news
    });
}
//获取未审核新闻
export function getUnreviewedNews(Num, Size) {
    return request({
        url: '/news/page',
        method: 'get',
        params: {
            pageNum: Num,
            pageSize: Size,
            isrelease: 0
        }
    });
}
//获取已审核新闻
export function getReviewedNews(Num, Size) {
    return request({
        url: '/news/page',
        method: 'get',
        params: {
            pageNum: Num,
            pageSize: Size,
            isrelease: 1
        }
    });
}
//根据是否审核搜索新闻
export function searchNews(Num, Size, search) {
    return request({
        url: '/news/page',
        method: 'get',
        params: {
            pageNum: Num,
            pageSize: Size,
            isrelease:search
        }
    });
}
//根据id删除新闻
export function deleteNews(id) {
    return request({
        url: "/news/" + id,
        method: "delete",
    });
}
//获取热搜新闻
export function getHotNews(num,size) {
    return request({
        url: '/news/page',
        method: 'get',
        params: {
            pageNum: num,
            pageSize:size,
            ishot: 1,
            isrelease: 1,
        },
    });
}
//获取已发布类别新闻
export function getNewsByType(type,num,size) {
    return request({
        url: '/news/page',
        method: 'get',
        params: {
            newclass: type,
            pageNum: num,
            pageSize:size,
            isrelease: 1,
        },
    });
}
//根据新闻标题搜索
export function searchNewsByTitle(title,num,size) {
    return request({
        url: '/news/page',
        method: 'get',
        params: {
            newtitle: title,
            pageNum: num,
            pageSize:size,
            isrelease: 1,
        },
    });
}
//审核多个新闻
export function reviewNews(ids) {
    return request({
        url: "/news/batchAudit",
        method: "post",
        params: {
            idList:ids.join(','),
            isRelease:1
        }
    });
}
